package simple3D.geom 
{
	import flash.geom.Point;
	/**
	 * Represents line with vector and start point
	 * x = x0 + vector.x*t
	 * y = y0 + vector.y*t
	 * @author Dmitriy Gaiduk
	 */
	public class Line2D 
	{
		public var startPoint:Point;
		public var vector:Point;
		
		public function Line2D() 
		{
			startPoint = new Point();
			vector = new Point();
		}
		
		public function buildFromPoints(p1:Point, p2:Point):void
		{
			startPoint = p1.clone();
			vector = new Point(p2.x - p1.x, p2.y - p1.y);
		}
		
		public function getYCoordAtX(x:Number):Number
		{
			if (vector.x == 0)
			{
				return NaN;
			}
			
			var t:Number = (x - startPoint.x) / vector.x;
			return (startPoint.y + vector.y * t);
		}
		
		
	}

}